//
//  TreeNode.m
//  LearnObjectiveC
//
//  Created by client on 2017/9/11.
//  Copyright © 2017年 吴可高. All rights reserved.
//

#import "TreeNode.h"

@interface TreeNode()

@property(nonatomic,strong,readwrite) NSMutableArray * childrens;

@end

@implementation TreeNode
@synthesize name,parent;

-(instancetype)initWithName:(NSString*)newName;
{
    self = [super init];
    if (self) {
        _childrens = [NSMutableArray array];
        name = newName;
    }
    return self;
}

-(void)setName:(NSString *)newName
{
    name = newName;
}

-(NSString *)name
{
    return name;
}

-(void)setParent:(TreeNode *)newParent
{
    parent = newParent;
}

-(TreeNode *)parent
{
    return parent;
}

-(void)addNode:(TreeNode*)node;
{
    [_childrens  addObject:node];
}

-(void)removeNode:(TreeNode*)node;
{
    [_childrens removeObject:node];
}

-(NSArray*)getChildrens;
{
    NSEnumerator * enumerator =  [_childrens objectEnumerator];
    return [enumerator allObjects];
}

@end
